﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace Coder.Workflow.Mapping
{
    public class WorkProcessMapping : IEntityTypeConfiguration<WorkProcess>
    {
        public void Configure(EntityTypeBuilder<WorkProcess> builder)
        {
            builder.HasKey(_ => _.Id);
            builder.Property(_ => _.Id).ValueGeneratedOnAdd();
            builder.HasDiscriminator(f => f.WorkflowType);
            builder.Property(f => f.WorkflowType).HasMaxLength(32);
            ;
            //builder.Ignore(f => f.NumberGenerator);
            builder.Property(_ => _.Name)
                .HasMaxLength(24);

            builder.HasMany(_ => _.Items);

            builder.HasIndex(_ => _.Name).IsUnique(true);
        }
    }
}